package com.game.module.semiInterface
{
	import com.game.event.GameEvent;
	
	import config.Config;
	
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.utils.setTimeout;
	
	public class ChanllengThreePrince extends Sprite
	{
		
		public function ChanllengThreePrince()
		{
			super();
			this.gc = Config.getIns();
			this.addEventListener(Event.ADDED_TO_STAGE, this.added, false, 0, true);
			this.addEventListener(Event.REMOVED_FROM_STAGE, this.removed, false, 0, true);
		}
		
		public var xbtn:SimpleButton;
		public var mc1:MovieClip;
		
		public var mc2:MovieClip;
		
		public var mc3:MovieClip;
		
		public var txt:TextField;
		
		public var costbtn:SimpleButton;
		private var bossID:uint;
		private var gc:Config;
		
		private function setTxt():void
		{
			this.txt.text = 999 + "";
		}
		
		private function gotoFuBen():void
		{
			this.gc.curStage = 44;
			this.gc.curLevel = this.bossID;
			if (this.parent)
			{
				this.parent.removeChild(this);
			}
		}
		
		private function added(param1:Event):void
		{
			this.mc1.buttonMode = true;
			this.mc2.buttonMode = true;
			this.mc3.buttonMode = true;
			this.mc1.addEventListener(MouseEvent.CLICK, this.mcClick);
			this.mc2.addEventListener(MouseEvent.CLICK, this.mcClick);
			this.mc3.addEventListener(MouseEvent.CLICK, this.mcClick);
			this.xbtn.addEventListener(MouseEvent.CLICK, this.xClick);
			this.setTxt();
		}
		
		private function removed(param1:Event):void
		{
			this.xbtn.removeEventListener(MouseEvent.CLICK, this.xClick);
			this.mc1.removeEventListener(MouseEvent.CLICK, this.mcClick);
			this.mc2.removeEventListener(MouseEvent.CLICK, this.mcClick);
			this.mc3.removeEventListener(MouseEvent.CLICK, this.mcClick);
		}
		
		private function mcClick(param1:MouseEvent):void
		{
			var _lc2_:Number = NaN;
			_lc2_ = Math.random();
			if (_lc2_ < 0.3333)
			{
				this.bossID = 1;
			}
			else if (_lc2_ >= 0.3333 && _lc2_ < 0.6666)
			{
				this.bossID = 2;
			}
			else
			{
				this.bossID = 3;
			}
			trace("Boss ->>" + this.bossID);
			param1.target.gotoAndStop(this.bossID + 1);
			this.mc1.removeEventListener(MouseEvent.CLICK, this.mcClick);
			this.mc2.removeEventListener(MouseEvent.CLICK, this.mcClick);
			this.mc3.removeEventListener(MouseEvent.CLICK, this.mcClick);
			setTimeout(this.gotoFuBen, 1000);
		}
		
		private function xClick(param1:MouseEvent):void
		{
			if (this.parent)
			{
				this.parent.removeChild(this);
			}
		}
	}
}
